//226. 翻转二叉树
//思路：1. 将一棵树从中间分开看作左右两棵树
//2. 先走到叶子节点，分别将根的叶子节点互换，交换完后再往上走到根节点(要将每次的根节点保存起来)
//3. 最后交换左右两棵子树

#include <stdlib.h>
struct TreeNode {
	int val;
	struct TreeNode* left;
	struct TreeNode* right;
};
struct TreeNode* invertTree(struct TreeNode* root) {
	if (NULL == root)
		return NULL;

	struct TreeNode* left = invertTree(root->left);
	struct TreeNode* right = invertTree(root->right);
	root->left = right;
	root->right = left;

	return root;
}
